package practice02;

import java.util.Arrays;
import java.util.Random;

public class GetArrayMaxNum {
    public static void main(String[] args) {
//        int n=new Random().nextInt(15);
        int[] a=new int[10];
        for (int i=0;i<a.length;i++){
            a[i]=new Random().nextInt(100);
        }
        System.out.println(Arrays.toString(a));
        maxNum(a);
        System.out.println(maxNum(a));
    }

    private static int maxNum(int[] a) {
        int max=0;
        if (a.length==1){
            max=a[0];
            return max;
        }else {
            for (int i=1;i<a.length;i++){
                max=a[i-1]>a[i]?a[i-1]:a[i];
                a[i]=max;
            }

        }

        return max;
    }
}
